package com.posjiajia.user.core.bo;

import com.posjiajia.user.core.contant.Constants;
import org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 序列
 * Created by zhenhua.sun on 8/24/16.
 */
@Service
public class SequenceBo {

    @Resource(name = "generateUserNo")
    private MySQLMaxValueIncrementer userIncrementer;

    @Resource(name = "generateOrganNo")
    private MySQLMaxValueIncrementer organIncrementer;

    /**
     * 获取下一个用户Id
     * @return
     */
    public Long getNextUserId(){
        return Constants.USER_ID_BASE + userIncrementer.nextLongValue();
    }

    /**
     * 获取下一个组织号
     * @return
     */
    public Integer getNextOrganId() {
        return Constants.ORGAN_ID_BASE + organIncrementer.nextIntValue();
    }
}
